package br.ufrj.neg.util;

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.PropertyResourceBundle;

public class PropertyLoader {

	private PropertyResourceBundle ppt_pt,ppt_en,ppt_es,ppt_de;
	private PropertyResourceBundle ppt_locais,ppt_eneg,ppt_database;
	
	private static PropertyLoader instance;
	
	public PropertyLoader() throws UnsupportedEncodingException, IOException{
		if(instance == null){
			createNewPropretyLoader();
			instance = this;
		}

	}
	
	public static PropertyLoader getPropertyLoader(){
		try{
			if( instance == null){
				return new PropertyLoader();
			}
		}catch(UnsupportedEncodingException ex){
			ex.printStackTrace();
		}
		catch(IOException ex){
			ex.printStackTrace();
		}
		return instance;
	}
	
	private void createNewPropretyLoader() throws UnsupportedEncodingException, IOException{
		ppt_pt = new PropertyResourceBundle(getClass().getClassLoader().getResourceAsStream("idioma-pt.properties"));
		ppt_en = new PropertyResourceBundle(getClass().getClassLoader().getResourceAsStream("idioma-en.properties"));
		ppt_es = new PropertyResourceBundle(getClass().getClassLoader().getResourceAsStream("idioma-es.properties"));
		ppt_de = new PropertyResourceBundle(getClass().getClassLoader().getResourceAsStream("idioma-de.properties"));
		
		ppt_locais = new PropertyResourceBundle(getClass().getClassLoader().getResourceAsStream("locais.properties"));
		ppt_eneg = new PropertyResourceBundle(getClass().getClassLoader().getResourceAsStream("eneg.properties"));
		ppt_database = new PropertyResourceBundle(getClass().getClassLoader().getResourceAsStream("database.properties"));		
	}

	public PropertyResourceBundle getPpt_pt() {
		return ppt_pt;
	}

	public PropertyResourceBundle getPpt_en() {
		return ppt_en;
	}
	
	public PropertyResourceBundle getPpt_es() {
		return ppt_es;
	}	
	
	public PropertyResourceBundle getPpt_de() {
		return ppt_de;
	}	

	public PropertyResourceBundle getPpt_locais() {
		return ppt_locais;
	}

	public PropertyResourceBundle getPpt_eneg() {
		return ppt_eneg;
	}

	public PropertyResourceBundle getPpt_database() {
		return ppt_database;
	}
	

	
	
}
